package cn.lyq.card.ui.statistics

import android.widget.ImageView
import cn.lyq.card.R
import cn.lyq.card.data.model.DevActDetailInfo
import cn.lyq.card.utils.loadUrl
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.module.LoadMoreModule
import com.chad.library.adapter.base.viewholder.BaseViewHolder


class DevProxyDetailAdapter : BaseQuickAdapter<DevActDetailInfo, BaseViewHolder>
    (R.layout.item_dev_proxy_detail, mutableListOf()), LoadMoreModule {

    private var isAct = true
    private var str = ""

    fun setIsAct(boolean: Boolean) {
        isAct = boolean
        str = if (boolean) "激活时间：" else "采购时间："
    }

    override fun convert(holder: BaseViewHolder, item: DevActDetailInfo) {
        holder.getView<ImageView>(R.id.imgDevice).loadUrl(item.img)
        holder.setText(R.id.tvDeviceName, "机具类型：${item.title}")
        holder.setText(R.id.tvSn, "SN：${item.posSn}")
        holder.setText(R.id.tvTime, "${str}${if (isAct) item.actTime else item.purchaseTime}")
    }
}